//
//  LZTabBarController.m
//  LZBS
//
//  Created by 郝庆 on 16/6/8.
//  Copyright © 2016年 haoqing. All rights reserved.
//

#import "LZTabBarController.h"
#import "LZNavigationController.h"
#import "LZEssenceViewController.h"
#import "LZNewViewController.h"
#import "LZFollowViewController.h"
#import "LZMeViewController.h"
#import "LZTabBar.h"

@interface LZTabBarController ()

@end

@implementation LZTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 创建所有的子控制器
    [self setUpAllChildControllers];
    
    // 更换TabBar
    [self setValue:[[LZTabBar alloc] init] forKey:@"TabBar"];

}

#pragma mark - 创建所有的子控制器
- (void)setUpAllChildControllers
{
    // 精华
    [self setUpOneChildController:[[LZEssenceViewController alloc] init] imageName:@"tabBar_essence_icon" selImageName:@"tabBar_essence_click_icon" title:@"精华"];
    // 新帖
    [self setUpOneChildController:[[LZNewViewController alloc] init] imageName:@"tabBar_new_icon" selImageName:@"tabBar_new_click_icon" title:@"新帖"];
    // 关注
    [self setUpOneChildController:[[LZFollowViewController alloc] init] imageName:@"tabBar_friendTrends_icon" selImageName:@"tabBar_friendTrends_click_icon" title:@"关注"];
    // 我
    [self setUpOneChildController:[[LZMeViewController alloc] init] imageName:@"tabBar_me_icon" selImageName:@"tabBar_me_click_icon" title:@"我"];
}

// 创建一个子控制器
- (void)setUpOneChildController:(UIViewController *)vc imageName:(NSString *)imageName selImageName:(NSString *)selImageName title:(NSString *)title
{
    LZNavigationController *nav = [[LZNavigationController alloc] initWithRootViewController:vc];
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selImageName];
    [self addChildViewController:nav];
}

@end
